// components/customer-service/index.js
import {router} from '../../js/router';
import authorize from '../../js/modules/authorize.js'
const componentBehavior = require('../../js/common/ComponentBehavior')

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    hasLive:{
      type:Boolean,
      value:false
    },
    hasService:{
      type:Boolean,
      value:false
    },
    hasPhone:{
      type:Boolean,
      value:false
    },
    phone:{
      type:String,
      value:''
    },
    hasJizhipai:{
      type:Boolean,
      value:false
    },    
    distributorCustomNo:{
      type:String,
      value:''
    }
    ,
    consumerNo:{
      type:String,
      value:''
    }
  },

  behaviors: [componentBehavior],
  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    goLive:function(){
      router.navigate({
        path:'live'
      })
    },
    phoneCall:function(){
      wx.makePhoneCall({
        phoneNumber: this.data.phone,
      })
    },
    gjp366go:function(){
      var storeInfo = authorize.getEntity()      
      var openpath = 'pages/common/loading/index?'  // 参数url方式拼接
      if (storeInfo == null) {
        openpath += 'form=012&distributorCustomNo=' + this.data.distributorCustomNo  
      }
      else
      {
        openpath += 'form=012&distributorCustomNo=' + this.data.distributorCustomNo + '&consumerNo=' + storeInfo.role.Code + '&phone=' + storeInfo.role.Tel +'&companyName=' + storeInfo.role.Name // 
      }    
      wx.navigateToMiniProgram({
        appId: 'wx412e9fe00f4ed8cf', 
        path:openpath,
        success: (res) => {
          // 打开成功
          console.log(res)
        },
        fail: (err) => {
          // 打开失败
          console.log(err)
        },
        complete: () => {
          // 接口调用结束
        }
      })

    }
  }
})
